Berlekamp-Massey algorithm